<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
  <title>Description of load_pattern_from_hd</title>
  <meta name="keywords" content="load_pattern_from_hd">
  <meta name="description" content="Reverse of MOVE_PATTERN_TO_HD">
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="generator" content="m2html &copy; 2003 Guillaume Flandin">
  <meta name="robots" content="index, follow">
  <link type="text/css" rel="stylesheet" href="../m2html.css">
</head>
<body>
<a name="_top"></a>
<!-- menu.html . -->
<h1>load_pattern_from_hd
</h1>

<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>Reverse of MOVE_PATTERN_TO_HD</strong></div>

<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>function [subj] = load_pattern_from_hd(subj,patname) </strong></div>

<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="fragment"><pre class="comment"> Reverse of MOVE_PATTERN_TO_HD

 [SUBJ] = LOAD_PATTERN_FROM_HD(SUBJ,PATNAME)

 Reloads a pattern that was saved to the harddisk. Uses the MOVEHD
 field stored in the pattern to retrieve things, and then removes it
 afterwards</pre></div>

<!-- crossreference -->
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
This function calls:
<ul style="list-style-image:url(../matlabicon.gif)">
<li><a href="add_history.html" class="code" title="function [subj] = add_history(subj,objtype,objname,hist_str,displayme)">add_history</a>	Adds HIST_STR to OBJNAME's history field.</li><li><a href="exist_objfield.html" class="code" title="function [isthere] = exist_objfield(subj,objtype,objname,fieldname)">exist_objfield</a>	Checks whether the field exists</li><li><a href="get_mat.html" class="code" title="function [mat] = get_mat(subj,objtype,objname)">get_mat</a>	Returns the MAT field of the object</li><li><a href="get_objsubfield.html" class="code" title="function [val] = get_objsubfield(subj,objtype,objname,fieldname,subfieldname)">get_objsubfield</a>	Returns the subfield for this object</li><li><a href="remove_objfield.html" class="code" title="function [subj] = remove_objfield(subj,objtype,objname,fieldname)">remove_objfield</a>	Removes a field from the object</li><li><a href="set_mat.html" class="code" title="function [subj] = set_mat(subj,objtype,objname,newmat,varargin)">set_mat</a>	Updates the MAT contents of an object</li></ul>
This function is called by:
<ul style="list-style-image:url(../matlabicon.gif)">
</ul>
<!-- crossreference -->


<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function [subj] = load_pattern_from_hd(subj,patname)</a>
0002 
0003 <span class="comment">% Reverse of MOVE_PATTERN_TO_HD</span>
0004 <span class="comment">%</span>
0005 <span class="comment">% [SUBJ] = LOAD_PATTERN_FROM_HD(SUBJ,PATNAME)</span>
0006 <span class="comment">%</span>
0007 <span class="comment">% Reloads a pattern that was saved to the harddisk. Uses the MOVEHD</span>
0008 <span class="comment">% field stored in the pattern to retrieve things, and then removes it</span>
0009 <span class="comment">% afterwards</span>
0010 
0011 <span class="comment">% This is part of the Princeton MVPA toolbox, released under the</span>
0012 <span class="comment">% GPL. See http://www.csbmb.princeton.edu/mvpa for more</span>
0013 <span class="comment">% information.</span>
0014 
0015 
0016 <span class="comment">% Error Checking: Has this pattern been moved?</span>
0017 <span class="keyword">if</span> ~<a href="exist_objfield.html" class="code" title="function [isthere] = exist_objfield(subj,objtype,objname,fieldname)">exist_objfield</a>(subj,<span class="string">'pattern'</span>,patname,<span class="string">'movehd'</span>)
0018   <span class="comment">% if there's no movehd and that mat is full, then things are</span>
0019   <span class="comment">% probably fine</span>
0020   <span class="keyword">if</span> ~isempty(<a href="get_mat.html" class="code" title="function [mat] = get_mat(subj,objtype,objname)">get_mat</a>(subj,<span class="string">'pattern'</span>,patname))
0021     disp(sprintf(<span class="string">'Pattern %s has not been saved to the hard disk - continuing'</span>,patname));
0022   <span class="comment">% but if there's no movehd and the mat is empty, then there's probably a problem</span>
0023   <span class="keyword">else</span>
0024     error(sprintf(<span class="string">'Pattern %s has not been saved to the hard disk and mat is empty'</span>,patname));
0025   <span class="keyword">end</span>
0026 <span class="keyword">end</span>
0027 
0028 <span class="comment">% If so, where should it be?</span>
0029 fn = <a href="get_objsubfield.html" class="code" title="function [val] = get_objsubfield(subj,objtype,objname,fieldname,subfieldname)">get_objsubfield</a>(subj,<span class="string">'pattern'</span>,patname,<span class="string">'movehd'</span>,<span class="string">'pathfilename'</span>);
0030 
0031 <span class="comment">% Is the file where its supposed to be?</span>
0032 <span class="keyword">if</span> ~exist(fn,<span class="string">'file'</span>)
0033   <span class="keyword">if</span> ~exist([fn <span class="string">'.mat'</span>],<span class="string">'file'</span>)
0034     error(sprintf(<span class="string">'Pattern not found on HD (Relative link problem?):\nfile: %s'</span>,fn));
0035   <span class="keyword">else</span>
0036     fn = [fn <span class="string">'.mat'</span>];
0037   <span class="keyword">end</span>
0038 <span class="keyword">end</span>
0039 
0040 load(fn);
0041 
0042 <span class="comment">% Delete the movehd record</span>
0043 subj = <a href="remove_objfield.html" class="code" title="function [subj] = remove_objfield(subj,objtype,objname,fieldname)">remove_objfield</a>(subj,<span class="string">'pattern'</span>,patname,<span class="string">'movehd'</span>);
0044 
0045 subj = <a href="set_mat.html" class="code" title="function [subj] = set_mat(subj,objtype,objname,newmat,varargin)">set_mat</a>(subj,<span class="string">'pattern'</span>,patname,mat);
0046 
0047 <span class="comment">% Update the header information</span>
0048 hist_str = sprintf(<span class="string">'Loaded pattern %s from harddisk as %s'</span>, patname,fn);
0049 subj = <a href="add_history.html" class="code" title="function [subj] = add_history(subj,objtype,objname,hist_str,displayme)">add_history</a>(subj,<span class="string">'pattern'</span>,patname,hist_str,true);
0050 
0051 <span class="comment">% Delete the file from the HD; Avoid multiple copies</span>
0052 delete(fn);</pre></div>
<hr><address>Generated on Thu 08-Sep-2005 12:05:17 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/" target="_parent">m2html</a></strong> &copy; 2003</address>
</body>
</html>